package com.restaurantonlineorder.buyer.controller;

import com.restaurantonlineorder.buyer.feignclients.OrderFeignService;
import com.restaurantonlineorder.buyer.vo.reps.OrderRespVo;
import com.restaurantonlineorder.buyer.vo.req.OrderReqVo;
import com.restaurantonlineorder.response.BaseResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 熊宇
 * @date 2022/7/24 11:32
 * @description 点餐 控制器
 */
@RestController
@Validated
public class OrderController {

    @Resource
    private OrderFeignService orderFeignService;

    /**
     * 点餐
     */
    @PostMapping("/order")
    BaseResult order(@Valid @RequestBody OrderReqVo orderReqVo) {
        return orderFeignService.generateOrder(orderReqVo);
    }

    /**
     * 查看订单
     *
     * @param id
     * @return
     */
    @GetMapping("/order")
    BaseResult<OrderRespVo> queryOrder(@RequestParam("id") Long id) {
        BaseResult<OrderRespVo> orderRespVo = orderFeignService.queryOrder(id);
        return orderRespVo;
    }

}
